package  
{
	import net.flashpunk.Entity;
	import net.flashpunk.FP;
	import net.flashpunk.graphics.Image;
	import net.flashpunk.graphics.Spritemap;
	import net.flashpunk.masks.Pixelmask;
	import net.flashpunk.utils.Input;
	
	/**
	 * ...
	 * @author Donatello
	 */
	public class Player extends Entity
	{
		[Embed(source = "img/sheets/sheet.png")] private const PLAYER_ANIM:Class;
		[Embed(source = "img/sheets/hand3.png")] private const PLAYER_PIX:Class;
		private var playerAnim:Spritemap;
		
		private var pressed:Boolean = false;
		public var state:String = "walking";
		public var handWalking:Boolean = false;
		public var kitchen:Boolean = false;
		
		public function Player(px:Number=305,py:Number=500) 
		{
			playerAnim = new Spritemap(PLAYER_ANIM, 54,147);
			
			playerAnim.add("idle", [0], 10, true);
			playerAnim.add("walking", [1,2,3,4], 10, true);
			playerAnim.add("hand", [5, 6, 7], 10, false);
			playerAnim.add("handwalking", [10,11,12,13], 10, true);
			
			graphic = playerAnim;
			
			mask = new Pixelmask(PLAYER_PIX);
			type = "Player";
			
			x = px;
			y = py;
			
			playerAnim.play("walking");
			
		}
		
		
		override public function update():void
		{
			
			
		
			if(Input.mousePressed && !pressed)
			{
				pressed = true;
				
				if(!kitchen)
				{	
					if(!handWalking)
					{
						playerAnim.play("hand");
						state = "hand";
					}
					else
					{
						playerAnim.play("handwalking");
						state = "handwalking";
					}
				}
			}
			
			if (Input.mouseReleased)
			{	
				if (!kitchen)
				{
					pressed = false;
					playerAnim.play("walking");
					state = "walking";
				}
			}	
			
			if (state == "walking" || state=="handwalking")
				x += 1;
							
		}
		
	
		
	}

}